<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title><%= title %></title>

	<% include ../includes/head%>
</head>
<body>
<% include ../includes/header%>
	
	<div id="container-inner">
		<ul id="breadcrumb-wrapper">
        
	    	<li>
	            <a href="index.html">
                <ins>
				    <div class="br-left"></div>
				    <div class="br-mid">
				    	主页
				    </div><!--br-mid-->
				    <div class="br-right">
				    </div><!--br-right-->
                </ins>    
		        </a>
            </li>  
            
            <li>
	            <a href="blog.html">
                <ins>
				    <div class="br-left"></div>
				    <div class="br-mid">
				    	用户列表
				    </div><!--br-mid-->
				    <div class="br-right">
				    </div><!--br-right-->
                </ins>    
		        </a>
            </li>
            
           
            <li id="page-title">
          		用户列表
        	</li><!--page-title-->
        </ul>
        <div id="inner-border"></div>
        <div class="clear"></div>
        <div id="contentwrap-inner">
        	
			<div class="row">
			
				<table class="table table-hover table-bordered">
					<thead>
						<tr>
							<th>名字</th>
							<th>时间</th>					
							<th>查看</th>
							<th>修改</th>
							<th>删除</th>
						</tr>
						
						<tbody>
							<% for(var i = 0; i < users.length; i++){%>
							<tr class="item-id-<%= users[i].id%>">
								<td>
									<%= users[i].name%>
								</td>
								
								<td>
									<%= moment(users[i].meta.createdAT).format('YYYY/MM/DD') %>
								</td>
								<td>
									<a href="/userdetail/<%= users[i]._id %>"><%= users[i].name%></a>
								</td>
								<td>
									<a href="/userupdata/<%= users[i]._id %>">修改</a>
								</td>
								<td>
									<button type="button" data-id="<%= users[i]._id%>" class="btn btn-danger del">删除</button>		
								</td>
							</tr>
							<%}%>
						</tbody>
						
					</thead>
				</table>
			</div>
			<div class="clear"></div>
        </div>		
	</div>
	<% include ../includes/footer%>
	<script>
		$(function(){
		    $('.del').click(
		        function(e){
		            var target = $(e.target);
		            var id = target.data('id');
		            var tr  = $('.item-id-'+ id);
		            $.ajax({
		                type:'DELETE',
		                url:'/admin/userlist?id='+id
		            })
		                .done(function(reaults){
		                    if(reaults.success===1){
		                        if(tr.length>0){
		                            tr.remove();
		                        }
		                    }
		                })
		        }
		    )
		})
	</script>
</body>
</html>